package com.example.zlw.singpixdemo;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.IntDef;
import android.util.Log;
import android.widget.Toast;

public class MyService extends Service {
    private static final String TAG = "MyService";
    private ScreenBroadListener screenBroadListener;

    public MyService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.e(TAG, "onStartCommand: ");
        screenBroadListener = new ScreenBroadListener(this);
        screenBroadListener.registerBroadCast();
        return Service.START_STICKY;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.e(TAG, "onDestroy: " + "进程死亡");
        Toast.makeText(this, "服务停止了", Toast.LENGTH_SHORT).show();
    }
}
